package com.woniu.postbar.controller;

import com.woniu.common.entity.Result;
import com.woniu.postbar.service.IPostLikeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wu
 * @since 2023-05-20
 */
@RestController
@RequestMapping("/postLike")
@Api(tags = "点赞模块")
public class PostLikeController {

    @Autowired
    private IPostLikeService postLikeService;

    @PostMapping("/like/{postId}/{userId}")
    @ApiOperation("点赞")
    public Result<Object> likeInfo(
            Integer postId,
            Integer userId){
        return postLikeService.likePost(postId, userId);
    }

    @PostMapping("/dislike/{postId}/{userId}")
    @ApiOperation("取消点赞")
    public Result<Object> dislikeInfo(
            Integer postId,
            Integer userId){
        return postLikeService.dislikePost(postId, userId);
    }
}
